package algorithm;

public class leetcode_1109 {
    public int[] corpFlightBookings(int[][] bookings, int n) {
        int[] diff = new int[n+2];
        for(int[] booking:bookings){
            diff[booking[0]]+=booking[2];
            diff[booking[1]+1]-=booking[2];
        }
        int[] result= new int[n];
        result[0] = diff[1];
        for(int i=2;i<n+1;++i){
            result[i-1]=result[i-2]+diff[i];
        }
        return  result;
    }
}
